/*This is the algorithm to compute the maximum cycle length for HAILSTONE sequence between
 * A and B unsigned long integers. 
 *
 * Author- Ajeet Singh
 * http://uva.onlinejudge.org
 * id- ajeet.singh82
 * Contact- ajeet.singh82@gmail.com
 *
 * 
 * Algorithm: 
 * HSS_CYCLE_LEN len, num
 * 	a. len := no. of trailing zeros // n/2
 * 	b. num >>= len 
 * 	c. key :- hash_key(num)
 * 	d. if key < chache_size && chache[key] != 0 // num in chache no need to compute
 * 		retuurn len+chache[key]
 * 	e. else if(key < chache_size && chache[key] == 0 // num in not chache compute and update chache
 * 		chache[key] = 1 + HSS_CYCLE_LEN(num >> 1 + num +1) // 3n+1
 * 		return len + chache[key]
 * 	f. else
 * 		return 1 + len + HSS_CYCLE_LEN(num >> 1 + num +1) // 3n+1
 *
 *
 *
 * Build:
 * gcc hss.c -o hailstone.exe
 * Run:
 * $./hailstone
 * $ a b
 * ...
 */

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
#define ultype unsigned long 
#define ltype long

#define CHAR_BIT 8

ultype  Max(ultype x, ultype y) {
	return x ^ ((x ^ y) & -(x < y));
}

ultype  Min(ultype x, ultype y) {
	return y ^ ((x ^ y) & -(x < y));
}

ltype Abs(ltype v) {
	ltype mask = v >> ((sizeof(ltype) * CHAR_BIT) - 1);
	return (v + mask) ^ mask;
}

static unsigned long Mod37BitPosition[] = { 32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13, 4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9, 5, 20, 8, 19, 18 };

#define pre_guess_size  1003
static short pre_len[pre_guess_size] = {\
351,  354,  349,  375,  357,  370,  352,  352,  383,  352,  370,  352,  352,\
347,  347,  365,  347,  360,  347,  360,  355,  373,  355,  355,  355,  373,  386,  355,  355,  368,  368,  355,\
443,  350,  350,  368,  381,  350,  350,  368,  350,  350,  350,  350,  363,  407,  407,  363,  358,  389,  358,\
358,  358,  376,  376,  389,  389,  358,  358,  358,  358,  371,  371,  371,  371,  353,  353,  353,  371,  371,\
384,  384,  353,  353,  353,  353,  353,  371,  371,  353,  384,  353,  353,  353,  353,  353,  353,  353,  366,\
366,  366,  353,  441,  348,  348,  366,  379,  348,  348,  379,  379,  348,  348,  379,  348,  348,  348,  348,\
348,  410,  366,  366,  348,  361,  361,  348,  348,  361,  392,  392,  348,  348,  348,  348,  348,  348,  361,\
423,  361,  361,  361,  361,  379,  374,  361,  348,  348,  436,  361,  361,  361,  361,  361,  405,  374,  374,\
387,  405,  361,  449,  374,  356,  356,  356,  374,  374,  374,  387,  387,  356,  356,  418,  356,  356,  356,\
356,  356,  356,  356,  356,  374,  374,  387,  387,  369,  387,  356,  387,  400,  356,  356,  356,  356,  356,\
369,  369,  369,  369,  369,  387,  369,  369,  356,  356,  351,  444,  444,  369,  351,  351,  351,  369,  369,\
369,  369,  413,  382,  382,  351,  382,  351,  351,  382,  351,  351,  351,  351,  351,  351,  351,  413,  351,\
369,  369,  351,  382,  351,  382,  364,  382,  382,  351,  426,  395,  351,  351,  351,  351,  351,  351,  351,\
351,  351,  351,  395,  364,  426,  364,  364,  364,  364,  382,  382,  364,  377,  364,  364,  470,  351,  351,\
364,  395,  439,  364,  364,  364,  364,  408,  408,  408,  377,  377,  377,  377,  377,  408,  408,  364,  364,\
359,  452,  377,  359,  359,  359,  377,  421,  359,  390,  390,  390,  359,  359,  359,  359,  421,  359,  359,\
359,  359,  359,  359,  359,  359,  359,  359,  359,  377,  377,  377,  359,  372,  359,  390,  390,  372,  390,\
390,  359,  434,  372,  359,  359,  359,  359,  359,  359,  359,  359,  359,  359,  359,  403,  372,  372,  372,\
372,  372,  372,  372,  372,  403,  385,  372,  372,  403,  359,  359,  354,  447,  372,  372,  354,  354,  354,\
354,  372,  372,  372,  372,  372,  354,  385,  385,  385,  385,  385,  354,  354,  509,  385,  354,  354,  354,\
416,  354,  354,  354,  354,  354,  354,  354,  354,  354,  354,  354,  354,  416,  354,  354,  372,  372,  372,\
354,  354,  416,  354,  354,  385,  385,  385,  354,  367,  385,  354,  354,  354,  385,  385,  354,  429,  354,\
398,  354,  354,  354,  354,  354,  354,  354,  354,  354,  354,  354,  354,  367,  442,  398,  367,  367,  367,\
367,  367,  367,  367,  367,  385,  385,  380,  367,  367,  380,  354,  354,  354,  349,  398,  367,  380,  442,\
442,  367,  349,  349,  349,  367,  367,  367,  367,  367,  349,  349,  349,  411,  411,  380,  380,  380,  349,\
349,  504,  380,  349,  349,  349,  380,  380,  380,  380,  349,  349,  349,  349,  411,  380,  380,  380,  349,\
349,  349,  349,  349,  349,  349,  349,  349,  349,  349,  349,  349,  349,  349,  411,  411,  349,  349,  349,\
349,  367,  367,  367,  349,  349,  411,  367,  380,  349,  349,  362,  362,  349,  362,  380,  380,  362,  362,\
362,  380,  380,  349,  349,  349,  349,  349,  349,  380,  424,  380,  349,  349,  424,  362,  362,  424,  349,\
349,  393,  393,  393,  393,  349,  362,  349,  349,  349,  349,  349,  349,  349,  349,  349,  349,  349,  349,\
349,  349,  349,  362,  393,  393,  362,  362,  362,  424,  424,  362,  362,  362,  362,  362,  349,  349,  362,\
362,  362,  362,  362,  362,  362,  362,  362,  362,  380,  380,  380,  380,  362,  362,  375,  375,  362,  362,\
468,  393,  375,  393,  349,  349,  349,  349,  362,  362,  393,  362,  437,  393,  437,  437,  362,  362,  362,\
362,  362,  362,  375,  362,  362,  362,  362,  362,  362,  362,  406,  406,  406,  375,  375,  437,  375,  468,\
375,  375,  375,  375,  375,  375,  375,  375,  393,  406,  388,  388,  375,  406,  406,  388,  406,  406,  362,\
362,  357,  362,  375,  357,  450,  357,  450,  450,  375,  375,  357,  357,  357,  357,  357,  375,  375,  375,\
375,  419,  375,  375,  375,  375,  419,  357,  388,  388,  388,  388,  388,  388,  357,  357,  525,  388,  357,\
388,  357,  357,  357,  357,  357,  401,  419,  419,  357,  357,  357,  357,  357,  357,  357,  357,  357,  357,\
357,  357,  357,  357,  357,  357,  357,  357,  419,  357,  357,  357,  375,  375,  375,  375,  388,  357,  375,\
357,  357,  370,  357,  388,  388,  388,  388,  370,  370,  370,  388,  388,  357,  388,  357,  357,  357,  432,\
388,  388,  357,  432,  370,  357,  401,  401,  357,  357,  357,  357,  357,  370,  370,  357,  357,  357,  357,\
357,  357,  357,  370,  357,  357,  401,  445,  401,  370,  370,  370,  370,  370,  370,  370,  370,  370,  370,\
370,  370,  370,  370,  370,  383,  401,  388,  388,  388,  401,  383,  370,  383,  445,  370,  370,  370,  370,\
476,  383,  401,  401,  357,  357,  357,  357,  357,  352,  352,  370,  383,  352,  432,  445,  445,  445,  383,\
370,  370,  370,  352,  352,  352,  352,  370,  370,  476,  383,  370,  370,  370,  370,  370,  370,  370,  370,\
370,  414,  352,  414,  414,  383,  383,  383,  383,  383,  352,  352,  445,  507,  383,  352,  352,  352,  352,\
383,  352,  352,  352,  352,  383,  383,  383,  383,  352,  352,  352,  352,  352,  352,  414,  383,  414,  414,\
383,  383,  352,  352,  352,  352,  352,  352,  352,  352,  352,  352,  352,  352,  352,  352,  352,  352,  352,\
352,  352,  352,  352,  352,  414,  414,  352,  352,  352,  352,  370,  370,  370,  383,  365,  352,  352,  414,\
383,  383,  352,  352,  352,  352,  352,  365,  352,  352,  458,  352,  383,  383,  383,  352,  365,  365,  365,\
365,  383,  383,  383,  383,  383,  352,  352,  352,  352,  383,  427,  383,  383,  383,  352,  427,  427,  365,\
352,  352,  352,  352,  396,  396,  396,  352,  352,  352,  352,  352,  352,  352,  352,  352,  352,  352,  365,\
365,  365,  352,  352,  352,  352,  352,  352,  352,  352,  352,  352,  365,  352,  352,  352,  352,  440,  396,\
396,  396};
static unsigned long pre_num[pre_guess_size] = {\
77031,  106239,  115547,  142587,  146599,  150015,  154062,  154063,  156159,  159359,  160411,  166011,\
166015,  173321,  178075,  180463,  186763,  189855,  192711,  195465,  205417,  206847,  211051,  212478,\
212479,  213881,  216367,  219899,  221353,  225023,  226587,  228399,  230631,  231094,  231095,  233191,\
234239,  237433,  239039,  240617,  247387,  249017,  249019,  249023,  254911,  263103,  270271,  270695,\
273889,  277615,  281401,  283305,  284783,  285174,  285175,  288489,  288615,  293198,  293199,  295131,\
295137,  298843,  300030,  300031,  308071,  308124,  308125,  308126,  310271,  310921,  312318,  312319,\
312603,  316577,  318718,  318719,  320263,  320822,  320823,  321003,  324551,  329151,  329849,  332022,\
332023,  332025,  332030,  332031,  336199,  337535,  339881,  342599,  345947,  346642,  346643,  349787,  351359,\
351679,  354303,  355143,  355591,  356150,  356151,  358063,  358559,  358777,  359967,  360297,  360303,  360361,\
 360926,  360927,  361129,  362343,  365185,  366985,  369087,  369567,  370153,  370155,  371081,  373526,  373527,\
373529,  373535,  373543,  375201,  376603,  377739,  379207,  379710,  379711,  380233,  381727,  382367,  385422,\
385423,  389191,  389871,  390930,  390931,  393511,  393967,  394655,  398457,  400041,  401151,  405407,  406043,\
410011,  410761,  410833,  410834,  410835,  413694,  413695,  414561,  416423,  416425,  422102,  422103,  423679,\
424956,  424957,  424958,  425503,  426651,  426655,  427017,  427175,  427762,  427763,  432734,  432735,  432811,\
432923,  434919,  437247,  438699,  439798,  439799,  442697,  442706,  442707,  448265,  449479,  450027,  450046,\
450047,  450651,  453174,  453175,  456798,  456799,  456891,  461262,  461263,  462107,  462188,  462189,  462190,\
465407,  466382,  466383,  466923,  467739,  468478,  468479,  468905,  474121,  474866,  474867,  477417,  478078,\
478079,  478369,  479931,  479935,  479983,  480395,  480481,  481215,  481234,  481235,  481505,  481959,  482239,\
486827,  486913,  487039,  488127,  489313,  492571,  493537,  493727,  494774,  494775,  498034,  498035,  498038,\
498039,  498046,  498047,  498057,  499647,  500271,  502137,  504299,  505609,  506281,  506303,  506977,  506983,\
507903,  508969,  509822,  509823,  511935,  513897,  513899,  514671,  515239,  518921,  519871,  521241,  524681,\
525289,  525543,  526206,  526207,  527039,  528895,  532715,  533387,  537095,  540542,  540543,  541390,  541391,\
543515,  546681,  547681,  547777,  547778,  547779,  551593,  554143,  554351,  555230,  555231,  555233,  555739,\
560295,  562802,  562803,  564905,  566609,  566610,  566611,  566955,  567337,  568807,  568811,  568873,  569566,\
569567,  569595,  570348,  570349,  570350,  571551,  572591,  573551,  576978,  576979,  577081,  577230,  577231,\
579007,  583787,  584007,  584807,  585327,  586396,  586397,  586398,  590262,  590263,  590267,  590274,  590275,\
590951,  591983,  596415,  597686,  597687,  599305,  600060,  600061,  600062,  600063,  601327,  601727,  601959,\
604233,  608111,  609063,  609065,  611455,  615017,  616142,  616143,  616248,  616250,  616252,  616253,  617767,\
620542,  620543,  621842,  621843,  623643,  624635,  624636,  624637,  624638,  624639,  625206,  625207,  626331,\
632161,  633154,  633155,  633159,  635519,  637436,  637437,  637438,  637825,  638255,  639913,  639977,  639983,\
640047,  640526,  640527,  640539,  640641,  640763,  640795,  641644,  641645,  641646,  642006,  642007,  642075,\
642985,  642987,  649051,  649102,  649103,  649215,  649217,  649385,  652379,  652417,  652527,  653739,  655871,\
656155,  656761,  657903,  658049,  658302,  658303,  659698,  659699,  664044,  664045,  664046,  664050,  664051,\
664060,  664061,  664062,  664063,  665215,  665979,  667375,  672398,  672399,  674145,  674219,  675041,  675070,\
675071,  675969,  675977,  678625,  679762,  679763,  683947,  685195,  685198,  685199,  685337,  686985,  687279,\
687871,  691894,  691895,  693161,  693284,  693285,  693286,  694987,  698111,  699574,  699575,  700385,  701595,\
701599,  701601,  701607,  701609,  702715,  702718,  702719,  703358,  703359,  704623,  705193,  707995,  708606,\
708607,  710286,  710287,  711182,  711183,  712299,  712300,  712301,  712302,  712683,  713575,  716126,  716127,\
717118,  717119,  717543,  717554,  717555,  719897,  719903,  719934,  719935,  719975,  720593,  720594,  720595,\
720606,  720607,  720722,  720723,  720795,  720859,  720895,  721823,  721852,  721853,  721854,  722258,  722259,\
722335,  722715,  722939,  723359,  723361,  724686,  724687,  726811,  728859,  730183,  730241,  730369,  730370,\
730371,  730559,  732191,  732399,  733927,  733970,  733971,  734043,  734091,  735457,  735679,  737371,  738174,\
738175,  738857,  739134,  739135,  739143,  740143,  740167,  740306,  740307,  740310,  740311,  740591,  740985,\
742162,  742163,  742183,  745711,  747052,  747053,  747054,  747057,  747058,  747059,  747070,  747071,  747086,\
747087,  747433,  747519,  749227,  749471,  750402,  750403,  750407,  753206,  753207,  755478,  755479,  755481,\
755943,  756449,  756873,  756903,  758409,  758414,  758415,  758491,  758497,  758511,  759420,  759421,  759422,\
759455,  760465,  760466,  760467,  760475,  761855,  761983,  763454,  763455,  764734,  764735,  767903,  769305,\
769441,  769641,  770844,  770845,  770846,  770849,  772007,  772009,  772859,  773247,  775035,  777327,  778382,\
778383,  779742,  779743,  779807,  781860,  781861,  781862,  785691,  787017,  787022,  787023,  787033,  787071,\
787934,  787935,  788315,  789310,  789311,  790555,  790559,  792735,  793343,  796095,  796914,  796915,  799023,\
799073,  799983,  800081,  800082,  800083,  801147,  801769,  802302,  802303,  805643,  807327,  810399,  810603,\
810814,  810815,  812086,  812087,  812251,  813055,  813307,  815273,  818943,  819967,  820022,  820023,  821522,\
821523,  821666,  821667,  821668,  821669,  821670,  823689,  827388,  827389,  827390,  827503,  829119,  829122,\
829123,  829543,  831215,  831527,  832839,  832846,  832847,  832849,  832850,  832851,  833609,  833775,  837799,\
839547,  840443,  842881,  844204,  844205,  844206,  844207,  844647,  845223,  847358,  847359,  849912,  849914,\
849916,  849917,  850433,  850975,  851006,  851007,  853211,  853217,  853255,  853275,  853302,  853303,  853310,\
853311,  854034,  854035,  854191,  854350,  854351,  854393,  855524,  855525,  855526,  855535,  855583,  856009,\
856551,  857313,  857327,  858887,  860327,  865401,  865468,  865469,  865470,  865622,  865623,  865627,  865846,\
865847,  868511,  869467,  869838,  869839,  869889,  871915,  874494,  874495,  874873,  875681,  876011,  877211,\
877398,  877399,  877737,  877991,  879596,  879597,  879598,  883903,  883995,  885393,  885394,  885395,  885401,\
885412,  885413,  885414,  885417,  885435,  886427,  886855,  886953,  887975,  889371,  889375,  889833,  894623,\
896530,  896531,  898855,  898958,  898959,  900054,  900055,  900092,  900093,  900094,  900095,  900511,  900735,\
901291,  901302,  901303,  901991,  902591,  902939,  904833,  906175,  906348,  906349,  906350,  908319,  910107,\
911929,  912167,  912511,  913593,  913595,  913596,  913597,  913598,  913782,  913783,  914971,  917161,  917183,\
919791,  922524,  922525,  922526,  922875,  924139,  924214,  924215,  924376,  924378,  924380,  924381,  926649,\
926651,  927003,  928191,  930814,  930815,  932764,  932765,  932766,  932767,  932779,  933846,  933847,  934299,\
935465,  935478,  935479,  936953,  936956,  936957,  936958,  936959,  937810,  937811,  938143,  939497,  940257,\
943899,  943975,  943993,  943995,  944491,  944809,  945403,  945499,  946119,  946623,  947049,  948242,  948243,\
949732,  949733,  949734,  949735,  949739,  949743,  950943,  951433,  952479,  953279,  954834,  954835,  956156,\
956157,  956158,  956187,  956738,  956739,  957383,  959862,  959863,  959870,  959871,  959913,  959935,  959966,\
959967,  959975,  960071,  960790,  960791,  960793,  960807,  960809,  960962,  960963,  961145,  961193,  962430,\
962431,  962468,  962469,  962470,  962631,  962667,  963010,  963011,  963113,  963918,  963919,  964287,  964478,\
964479,  964481,  966247,  966249,  969081,  970587,  970599,  971247,  973577,  973654,  973655,  973823,  973825,\
973826,  973827,  973831,  974078,  974079,  976254,  976255,  978151,  978569,  978626,  978627,  978791,  980609,\
980905,  982663,  983161,  983807,  984233,  985142,  985143,  985513,  986855,  986857,  986863,  986889,  987074,\
987075,  987081,  987454,  987455,  987739,  989547,  989548,  989549,  989550,  989551,  989577,  992895,  994281,\
994395,  994495,  995967,  996068,  996069,  996070,  996076,  996077,  996078,  996091,  996092,  996093,  996094,\
996095,  996114,  996115,  996577,  997231,  997823,  998969,  999294,  999295};

#define overflow_count 84

static short overflow_len[overflow_count] = {184,  187,  182,  185,  185,  180,  330,  193,  162,  242,  188,  188,  214,  183,  183,  333,  196,  196,  178,  165,  328,  191,  191,  204,  160,  240,  186,  186,  186,  199,  292,  292,  336,  212,  243,  181,  181,  194,  248,  331,  331,  194,  194,  194,  318,  331,  194,  176,  269,  344,  194,  163,  163,  243,  243,  326,  189,  189,  189,  189,  189,  313,  238,  202,  251,  215,  215,  308,  339,  339,  158,  264,  238,  184,  184,  184,  171,  184,  321,  233,  197,  290,  290,  303};

static unsigned long overflow_num[overflow_count] = {159487, 212649, 239231, 318974, 318975, 358847, 376831, 378043, 419839, 420351, 425298, 425299, 459759, 478462, 478463, 502441, 504057, 531183, 538271, 559785, 565247, 566719, 567065, 581883, 629759, 630527, 637948, 637949, 637950, 654619, 655359, 656415, 669921, 689639, 704511, 717694, 717695, 736447, 747291, 753662, 753663, 755625, 756086, 756087, 763675, 780391, 796775, 807407, 815871, 822139, 829087, 839678, 839679, 840702, 840703, 847871, 850079, 850596, 850597, 850598, 856731, 859135, 870171, 872825, 901119, 919518, 919519, 920559, 924907, 937599, 944639, 945435, 945791, 956924, 956925, 956926, 957211, 963823, 975015, 978943, 981929, 983039, 984623, 991935}; 


#define schache_size  0x400UL
static short precomputed_chache[schache_size] = {1,  8,  6,  17,  20,  15,  10,  18,  13,  21,  8,  16,  24,  112,\
19,  107,  27,  14,  22,  35,  110,  30,  17,  105,  25,  25,  12,  113,  33,  33,  20,  108,  28,  28,  15,  103,\
116,  15,  23,  36,  23,  111,  10,  31,  31,  93,  18,  106,  119,  26,  26,  88,  39,  101,  114,  70,  13,  34,\
21,  34,  96,  47,  109,  47,  122,  29,  29,  42,  91,  42,  16,  104,  117,  117,  24,  16,  37,  86,  37,  55,\
99,  24,  112,  68,  50,  125,  32,  81,  32,  32,  19,  94,  45,  45,  107,  45,  120,  120,  27,  120,  19,  40,\
27,  89,  40,  40,  14,  102,  27,  53,  115,  71,  53,  14,  35,  128,  84,  128,  35,  53,  22,  97,  22,  48,\
48,  66,  110,  48,  123,  123,  30,  79,  123,  22,  30,  43,  30,  92,  17,  43,  43,  61,  105,  43,  30,  118,\
118,  56,  74,  118,  17,  43,  38,  38,  25,  87,  131,  38,  38,  56,  25,  100,  25,  144,  51,  25,  113,  69,\
113,  51,  12,  126,  126,  126,  33,  82,  126,  33,  33,  51,  46,  46,  95,  46,  20,  46,  20,  46,  64,  59,\
108,  46,  33,  121,  121,  121,  59,  77,  28,  121,  20,  20,  28,  41,  41,  134,  90,  134,  134,  41,  41,\
33,  59,  54,  103,  41,  28,  28,  116,  54,  28,  54,  72,  98,  116,  54,  15,  41,  129,  129,  36,  129,  36,\
85,  23,  129,  36,  28,  36,  54,  49,  23,  98,  142,  49,  142,  49,  98,  23,  49,  111,  67,  62,  36,  49,\
62,  36,  124,  124,  62,  124,  124,  31,  80,  31,  124,  31,  23,  23,  49,  44,  137,  44,  31,  93,  44,  137,\
31,  44,  88,  44,  44,  18,  62,  57,  31,  106,  44,  31,  31,  119,  31,  57,  119,  119,  57,  75,  75,  26,\
119,  57,  70,  18,  44,  132,  39,  39,  70,  132,  132,  88,  132,  26,  132,  39,  39,  31,  31,  57,  132,  52,\
26,  101,  39,  145,  101,  26,  145,  52,  52,  114,  26,  52,  145,  70,  96,  65,  114,  52,  65,  65,  39,  127,\
39,  127,  127,  34,  127,  127,  65,  83,  171,  34,  127,  34,  65,  26,  26,  34,  52,  47,  47,  21,  47,  34,\
140,  96,  47,  140,  21,  47,  96,  91,  47,  47,  140,  21,  65,  109,  60,  34,  153,  47,  60,  34,  34,  122,\
153,  34,  60,  122,  122,  122,  60,  29,  78,  78,  104,  122,  73,  60,  21,  21,  73,  47,  135,  42,  135,  42,\
42,  29,  135,  135,  42,  91,  135,  29,  135,  42,  86,  42,  42,  42,  34,  60,  60,  16,  55,  29,  148,  104,\
42,  148,  29,  29,  179,  148,  29,  55,  148,  117,  29,  117,  55,  148,  47,  73,  99,  68,  117,  55,  117,\
68,  55,  16,  42,  130,  130,  37,  130,  130,  68,  130,  117,  130,  37,  86,  130,  174,  86,  130,  37,  37,\
37,  37,  29,  29,  29,  55,  130,  50,  50,  24,  143,  50,  37,  99,  143,  99,  50,  24,  143,  24,  37,  50,\
99,  94,  24,  50,  50,  143,  42,  68,  94,  112,  63,  112,  37,  156,  63,  50,  63,  37,  37,  125,  37,  156,\
125,  125,  63,  125,  125,  32,  125,  63,  94,  81,  169,  81,  32,  125,  76,  76,  63,  24,  169,  24,  24,  32,\
50,  138,  138,  45,  138,  45,  45,  32,  76,  138,  32,  94,  45,  94,  138,  19,  32,  138,  94,  45,  89,  45,\
45,  45,  138,  37,  37,  63,  63,  19,  58,  107,  32,  151,  58,  45,  58,  151,  32,  32,  58,  182,  151,  120,\
32,  58,  58,  120,  120,  32,  58,  58,  89,  151,  76,  76,  50,  102,  120,  120,  71,  58,  58,  19,  71,  58,\
71,  45,  164,  133,  133,  40,  133,  133,  133,  40,  71,  133,  133,  27,  133,  40,  71,  89,  133,  177,  27,\
133,  89,  40,  84,  40,  177,  40,  32,  40,  32,  32,  84,  58,  133,  53,  53,  27,  146,  146,  53,  102,  40,\
102,  146,  27,  102,  53,  177,  146,  102,  27,  53,  53,  146,  102,  53,  27,  53,  53,  53,  115,  146,  45,\
27,  71,  97,  115,  66,  115,  159,  40,  115,  53,  66,  53,  66,  14,  40,  40,  115,  128,  40,  159,  128,\
128,  97,  66,  66,  128,  115,  35,  128,  35,  66,  97,  128,  84,  172,  84,  35,  128,  35,  79,  128,  35,\
66,  27,  27,  35,  27,  27,  79,  53,  128,  141,  48,  48,  53,  141,  141,  48,  141,  35,  35,  97,  141,  35,\
141,  48,  172,  97,  141,  22,  97,  35,  141,  48,  97,  48,  92,  22,  48,  48,  48,  48,  141,  40,  22,  66,\
92,  66,  141,  61,  154,  110,  35,  110,  154,  61,  61,  48,  61,  154,  35,  35,  110,  61,  35,  123,  154, \
123,  35,  123,  61,  61,  154,  123,  61,  35,  123,  61,  61,  92,  123,  79,  167,  79,  79,  30,  105,  123,\
74,  123,  74,  61,  61,  22,  167,  74,  22,  22,  74,  48,  48,  30,  136,  136,  74,  43,  136,  136,  43,  43,\
105,  74,  74,  136,  136,  30,  136,  92,  43,  74,  43,  136,  74,  180,  30,  136,  43,  92,  136,  43,  87,  43,\
43,  43,  43,  35,  136,  35,  180,  35,  61,  61,  61,  136,  149,  56,  149,  30,  30,  105,  149,  56,  56,  43,\
56,  105,  149,  30,  105,  105,  56,  30,  180,  149,  149,  118,  30,  56,  43,  56,  149,  105,  118,  30,  149,\
56,  56,  56,  87,  118,  149,  74,  48,  30,  48,  100,  100,  118,  69,  118,  69,  162,  43,  56,  118,  56,  69,\
17,  56,  69,  162,  43,  162,  43,  131,  131,  69,  43,  131,  131,  162,  131,  131,  38,  69,  69,  131,  131,\
118,  38,  131,  38,  69,  69,  38,  87,  131,  87,  175,  25,  87,  38,  87,  131,  38,  82,  38,  38,  175,  69,\
69,  30,  131,  38,  30,  38,  30,  82,  175,  56,  131,  144,  51,  51,  51,  56,  144,  25,  144,  51,  51,  100,\
38,  38,  82,  144,  175,  38,  100,  51,  82,  175,  82,  144,  100,  25,  25,  51,  38,  144,  144,  100,  51,\
51,  95,  25,  51,  51,  51,  51,  51,  51,  144,  113,  43,  25,  43,  69,  95,  69,  113,  64,  157,  157,  157,\
38,  64,  113,  157,  51,  64,  64,  157,  64,  157}; 

/* _NO_CHACHE_ can be defined to run the algorithm without chaching
 * (Note: _NO_CHACHE_ dynamic chache of <schache_size> odd elements)
 * Algorith uses two types of chache to hash intermidiate results
 * A. Precomputed chache of <schache_size> odd elements < 2*<schache_size>
 * B. Dynamic on the fly chache of dchache_size to direct hash intermidiate
 *    odd elements, even elments are not chached, switch on the flag
 *
 *    With _NO_CHACHE_ / without _NO_CHACHE_ will change the time compleity
 *    by 10% for a = 1 b= 1000000
 */

#ifndef _NO_CHACHE_
#define dchache_size 0x0007FFFFUL   
#else
#define dchache_size 0x400UL 
#endif

static short dynamic_chache[dchache_size+1];
static short* chache[2]; 

#define stack_len 0x400
short running_stack_len[stack_len];
ultype running_stack_num[stack_len];

#define count_trailing_zeros(v) Mod37BitPosition[(-(v) & (v)) % 37]

/* Get hash Key
 *
 */
#define get_key(index, num) \
	(index == 0 ? ((num) >> 1) : (((num) >> 1)-schache_size))	

/* Update hash
*/ 
void update_hash(short hss_len) {
	short stack_ptr = 0;
	unsigned long key = 0;
	while((running_stack_len[stack_ptr] != -1)) {
		key = get_key(1, running_stack_num[stack_ptr]);
		if(key <= dchache_size) {
			chache[1][key] = hss_len-running_stack_len[stack_ptr];
		}
		stack_ptr++;
	}
}

/* Procedure to compute HSS cycle length for any unsigned number
*/
short Cal_hss_length(ultype num) {
	short hss_len = 0;
	unsigned short index = 0;
	unsigned long key = 0;
	short stack_ptr = -1;
	while(stack_ptr < stack_len-1) {
		/* If it is an Even number hss_len > 0
		 * Compute hss length till number becomes odd
		 */
		unsigned short trailing_zeros = count_trailing_zeros(num);
		num >>= trailing_zeros; 
		hss_len += trailing_zeros; 

		/* Select chache 0/1 
		 * and hash key
		 * */
		index = ((num & 0xFFFFF800UL) >> count_trailing_zeros(num & 0xFFFFF800UL))  & 0x01UL;
		key = get_key(index, num);


		/*   -----  It is an odd number -----
		 *	 a. check in chache for O(1) retrival
		 *	 b. Compute the hss length for this odd number
		 *	 and Hash the odd number > 2*<schache_size> in D-chache
		 **/
		if( (key <= dchache_size) && chache[index][key] != 0) {
			hss_len += chache[index][key];
			break;
		}
		//if(((((unsigned long)(0xffffffff-1)) >> 2) - ((unsigned long)(0xffffffff-1)))  < num) {
		//	goto DONE;
		//}

		stack_ptr++;
		running_stack_num[stack_ptr] = num;
		running_stack_len[stack_ptr] = hss_len;
		hss_len++;
		num = (num << 1) + num + 1;
	}
	/* update Hash Table 
	 * */
	stack_ptr++;
	running_stack_len[stack_ptr] = -1;
	update_hash(hss_len);
DONE:
	return hss_len;
}

/*Binary search
 *
 * */

short binary_search(unsigned long A [], unsigned long key, short imin, short imax) {
  while (imax >= imin) {
      int imid = imin + ((imax - imin) / 2);
      if(A[imid] <  key)
        imin = imid + 1;
      else if (A[imid] > key )
        imax = imid - 1;
      else
        return imid;
  }
  return -1;
}

short binary_search_2(unsigned long key, short imin, short imax) {
	while (imax >= imin) {
		int imid = imin + ((imax - imin) / 2);
		if(pre_num[imid] <  key)
			imin = imid + 1;
		else if (pre_num[imid] > key )
			imax = imid - 1;
		else
			return imid;
	}
	return imin;
}

void sub_array(unsigned long min, unsigned max, short& start, short& end) {
	if(min >= pre_num[pre_guess_size-1])
		start = pre_guess_size-1;
	else if(min <= pre_num[0])
		start = 0;
	else
		start = binary_search_2(min, 0, pre_guess_size-1);

	if(max >= pre_num[pre_guess_size-1])
		end = pre_guess_size-1;
	else if(max <= pre_num[0])
		end = 0;
	else
		end = binary_search_2(max, 0, pre_guess_size-1);
}

/* number having cycle greater than 346 are chached for O(1)
 * retriveal
 * */
short pre_guess(unsigned long min, unsigned long max) {
	short min_index = 0;
	short max_index = 0;
	sub_array(min, max, min_index, max_index);
	if(min_index < max_index)
		return *max_element(pre_len+min_index, pre_len+max_index);
	else
		return 0;
}

/*Calculate max hailstone length between a , b
 *
 * */
short Max_hss_length(ultype num,  long len) {
	if (num == 0) return 0;
	short max_sofar = 0;
	
	if(len == 0 && num >= pre_num[0] && num <= pre_num[pre_guess_size-1]) {
		short index = binary_search(pre_num, num, 0, pre_guess_size-1);
		if(index != (short)(-1))
			return pre_len[index];
	}
	if(len != 0) {
		max_sofar = pre_guess(num, num+len);
		if(max_sofar != 0)
			return max_sofar;
	}

	while (len-- >= 0) {
#if 0
		short index = -1;
		if( num >= overflow_num[0] && num <= overflow_num[overflow_count-1]){
			index = binary_search(overflow_num, num, 0, overflow_count-1);
		}
		if(index != (short)(-1)) {
			max_sofar = Max(max_sofar, overflow_len[index]);
			num++;
		}
		else {
#endif			
			max_sofar = Max(max_sofar, Cal_hss_length(num++));
#if 0			
		}
#endif
	}
	return max_sofar;
}

/* main
 * this will wait for two space separated inputs a b till EOF 
 * */

int main() {
	ultype start=0, end=0;
	short max_len=0;
	memset(dynamic_chache, 0 , dchache_size+1);
	chache[0] = precomputed_chache;
	chache[1] = dynamic_chache;
	while (scanf("%lu %lu", &start, &end ) != EOF) {
		max_len = Max_hss_length(Min(start, end), Abs(start-end));
		printf("%lu %lu %hi\n", start, end, max_len);
	}
	return 0;
}
